package leetcode.to1000;

/**
 * 位运算的模拟
 * &，和运算，
 */
public class T0318 {
    public int maxProduct(String[] words) {
        int n = words.length;
        int[] nums = new int[n];
        int dex = 0;
        for (String word : words) {
            int t = 0;
            for (int i = 0; i < word.length(); i++) {
                int u = word.charAt(i) - 'a';
                t |= (1 << u);
            }
            nums[dex++] = t;
        }
        int res=0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < i; j++) {
                if ((nums[i]&nums[j])==0){
                    res=Math.max(res,words[i].length()*words[j].length());
                }
            }
        }
        return res;
    }

}
